import { observable, action } from '@/miniprogram_npm/mobx-miniprogram/index';

const userStore = observable({
    userInfo: observable.object({}),

    setUserInfo: action(function (payload) {
        this.userInfo = payload;
    }),

    updateUserInfo: action(function (key, value) {
        this.userInfo = {
            ...this.userInfo,
            [key]: value
        };
    }),

    resetAll: action(function () {
        this.userInfo = {};
        this.token = '';
    }),

    getUserInfo() {
        return this.userInfo;
    }
});

export default userStore;
